<template>
  <div class="user-management-container">
    <!-- <vab-query-form>
      <vab-query-form-left-panel :span="12">
        <el-select v-model="value" clearable placeholder="请选择审核状态">
          <el-option
            v-for="item in options1"
            :key="item.id"
            :label="item.creClasName"
            :value="item.id"
            @click.native="optosall(item)"
          />
        </el-select>

        <el-date-picker
          v-model="PayTime"
          end-placeholder="结束日期"
          range-separator="至"
          start-placeholder="开始日期"
          style="margin-left: 20px"
          type="daterange"
          @change="GetzhifuTime"
        />
      </vab-query-form-left-panel>
      <vab-query-form-right-panel :span="12">
        <el-form :inline="true" :model="queryForm" @submit.native.prevent>
          <el-form-item>
            <el-input
              v-model.trim="queryForm.keyWord"
              clearable
              placeholder="请输入用户名"
            />
          </el-form-item>
          <el-form-item>
            <el-button icon="el-icon-search" type="primary" @click="queryData">
              查询
            </el-button>
          </el-form-item>
        </el-form>
      </vab-query-form-right-panel>
    </vab-query-form> -->

    <el-table
      v-loading="listLoading"
      border
      :data="list"
      @selection-change="setSelectRows"
    >
      <el-table-column align="center" show-overflow-tooltip type="selection" />
      <el-table-column
        align="center"
        label="id"
        prop="id"
        show-overflow-tooltip
      />
      <!-- <el-table-column align="center" label="用户头像">
        <template slot-scope="scope">
          <img :src="scope.row.headPortrait" />
        </template>
      </el-table-column> -->

      <el-table-column align="center" label="类别" show-overflow-tooltip>
        <template slot-scope="scope">
          <!-- * 分类 0-举报 1-功能 2-意见 3-申诉 4-其他 -->
          <template v-if="scope.row.classify == 0">
            <span style="color: red">演员长时间未登录或事项申请冻结</span>
          </template>
          <template v-else-if="scope.row.classify == 1">
            <span style="color: gray">演员分数低冻结</span>
          </template>
          <template v-else-if="scope.row.classify == 2">
            <span style="color: gray">管理端冻结</span>
          </template>
          <template v-else-if="scope.row.classify == 3">
            <span style="color: gray">剧组冻结</span>
          </template>
          <template v-else-if="scope.row.classify == 4">
            <span style="color: gray">领队冻结</span>
          </template>
          <!-- <template v-else-if="scope.row.relevant == 5">
            <span style="color: red">演员账号冻结</span>
          </template> -->
        </template>
      </el-table-column>
      <el-table-column
        align="center"
        label="反馈内容"
        prop="feedbackContent"
        show-overflow-tooltip
      />
      <el-table-column
        align="center"
        label=" 联系方式"
        prop="contactMode"
        show-overflow-tooltip
      />
      <el-table-column align="center" label="反馈图片">
        <template #default="{ row }">
          <!-- <div v-for="(item, index) in row.feedbackPictures" :key="index">
            <el-image :key="index" :preview-src-list="imageList" :src="item" />
          </div> -->
          <el-button type="text" @click="handleEdit(row)">查看详情</el-button>
        </template>
      </el-table-column>

      <el-table-column align="center" label="反馈状态" show-overflow-tooltip>
        <template slot-scope="scope">
          <template v-if="scope.row.feedbackStatus == 0">
            <span style="color: red">待处理</span>
          </template>
          <template v-else-if="scope.row.feedbackStatus == 1">
            <span style="color: green">已处理</span>
          </template>
        </template>
      </el-table-column>
      <el-table-column
        align="center"
        label="创建时间"
        prop="createTime"
        show-overflow-tooltip
      />

      <el-table-column
        align="center"
        label="操作"
        show-overflow-tooltip
        width="130"
      >
        <template #default="{ row }">
          <template v-if="row.classify == 0">
            <el-button type="text" @click="handleEditsj(row)">
              申请解冻
            </el-button>
          </template>
          <template v-if="row.classify == 1">
            <el-button type="text" @click="handleEditfs(row)">
              分数低解冻
            </el-button>
          </template>
          <template v-if="row.classify == 2">
            <el-button type="text" @click="handleEditpc(row)">
              管理端解冻
            </el-button>
          </template>
          <template v-if="row.classify == 3">
            <el-button type="text" @click="handleEditpclingdui(row)">
              剧组解冻
            </el-button>
          </template>
          <template v-if="row.classify == 4">
            <el-button type="text" @click="handleEditpcjvzu(row)">
              领队解冻
            </el-button>
          </template>
          <el-button type="text" @click="handleEdittwo(row)">处理</el-button>
        </template>
      </el-table-column>
      <template #empty>
        <el-image
          class="vab-data-empty"
          :src="require('@/assets/empty_images/data_empty.png')"
        />
      </template>
    </el-table>
    <el-pagination
      background
      :current-page="queryForm.pageNum"
      :layout="layout"
      :page-size="queryForm.pageSize"
      :total="total"
      @current-change="handleCurrentChange"
      @size-change="handleSizeChange"
    />
    <edit ref="edit" @fetch-data="fetchData" />
    <Edittwo ref="Edittwo" @fetch-data="fetchData" />
    <Editthree ref="Editthree" @fetch-data="fetchData" />
    <Editfour ref="Editfour" @fetch-data="fetchData" />
    <Editfive ref="Editfive" @fetch-data="fetchData" />
    <Editsix ref="Editsix" @fetch-data="fetchData" />
    <Editseven ref="Editseven" @fetch-data="fetchData" />
  </div>
</template>

<script>
  // , doDelete
  import { getListwo } from '@/api/fankui'
  import Edit from './model/tupian.vue'
  import Edittwo from './model/chuli.vue'
  import Editthree from './model/csjjdong.vue'
  import Editfour from './model/fsjiedong.vue'
  import Editfive from './model/pcdong.vue'
  import Editsix from './model/lingduijie.vue'
  import Editseven from './model/jvzujie.vue'

  export default {
    name: 'UserManagement',
    // Edit,
    components: {
      Edittwo,
      Edit,
      Editthree,
      Editfour,
      Editfive,
      Editsix,
      Editseven,
    },
    data() {
      return {
        PayTime: '', //时间条件查询
        value: '',
        options1: [
          {
            id: '0',
            creClasName: '未审核',
          },
          {
            id: '1',
            creClasName: '审核中',
          },
          {
            id: '2',
            creClasName: '审核通过',
          },
          {
            id: '3',
            creClasName: '审核未通过',
          },
        ], //审核状态
        list: [],
        listLoading: true,
        layout: 'total, sizes, prev, pager, next, jumper',
        total: 0,
        selectRows: '',
        imageList: [],
        queryForm: {
          pageNum: 1,
          pageSize: 10,
          // name: '',
          // nickname: '',
          // openId: '',
          // locked: '',
          // phone: '',
          // headPortrait: '',
        },
      }
    },
    created() {
      this.fetchData()
    },
    methods: {
      tableSortChange() {
        const imageList = []
        this.$refs.tableSort.tableData.forEach((item) => {
          imageList.push(item.img)
        })
        this.imageList = imageList
      },
      setSelectRows(val) {
        this.selectRows = val
      },
      handleEdit(row) {
        console.log(row)
        if (row.id) {
          this.$refs['edit'].showEdit(row)
        } else {
          this.$refs['edit'].showEdit()
        }
      },
      handleEdittwo(row) {
        console.log(row)
        if (row.id) {
          this.$refs['Edittwo'].showEdit(row)
        } else {
          this.$refs['Edittwo'].showEdit()
        }
      },
      handleEditsj(row) {
        //长时间未登录
        console.log(row)
        if (row.id) {
          this.$refs['Editthree'].showEdit(row)
        } else {
          this.$refs['Editthree'].showEdit()
        }
      },
      handleEditpclingdui(row) {
        //领队解冻
        console.log(row)
        if (row.id) {
          this.$refs['Editsix'].showEdit(row)
        } else {
          this.$refs['Editsix'].showEdit()
        }
      },
      handleEditpcjvzu(row) {
        //剧组解冻
        console.log(row)
        if (row.id) {
          this.$refs['Editseven'].showEdit(row)
        } else {
          this.$refs['Editseven'].showEdit()
        }
      },
      handleEditfs(row) {
        //分数低
        console.log(row)
        if (row.id) {
          this.$refs['Editfour'].showEdit(row)
        } else {
          this.$refs['Editfour'].showEdit()
        }
      },
      handleEditpc(row) {
        if (row.id) {
          this.$refs['Editfive'].showEdit(row)
        } else {
          this.$refs['Editfive'].showEdit()
        }
      },
      optosall(e) {
        //条件查询
        this.queryForm.leaderCheck = e.id
        this.queryForm.pageNum = 1
        this.fetchData()
      },
      // handleEditee(row) {
      //   if (row.id) {
      //     this.$baseConfirm('你确定要停用当前项吗', null, async () => {
      //       const { msg } = await doDelete({ id: row.id })
      //       this.$baseMessage(msg, 'success', 'vab-hey-message-success')
      //       await this.fetchData()
      //     })
      //   } else {
      //     if (this.selectRows.length > 0) {
      //       const id = this.selectRows.map((item) => item.id).join()
      //       this.$baseConfirm('你确定要停用当前项吗', null, async () => {
      //         const { msg } = await doDelete({ id })
      //         this.$baseMessage(msg, 'success', 'vab-hey-message-success')
      //         await this.fetchData()
      //       })
      //     } else {
      //       this.$baseMessage('未选中任何行', 'error', 'vab-hey-message-error')
      //     }
      //   }
      // },
      handleSizeChange(val) {
        this.queryForm.pageSize = val
        this.fetchData()
      },
      handleCurrentChange(val) {
        this.queryForm.pageNum = val
        this.fetchData()
      },
      queryData() {
        this.queryForm.pageNum = 1
        this.fetchData()
      },
      // async fetchData() {
      //   this.listLoading = true
      //   const {....
      //     data: { list, total },
      //   } = await getList(this.queryForm)
      //   this.list = list
      //   this.total = total
      //   this.listLoading = false
      // },
      async fetchData() {
        this.listLoading = true
        const res = await getListwo(this.queryForm)

        this.list = res.data

        this.total = res.total
        this.listLoading = false
        const imageList = []
        res.data.forEach((item) => {
          imageList.push(item.feedbackPictures)
        })
        this.imageList = imageList
      },
      //支付时间戳设置
      GetzhifuTime() {
        if (this.PayTime) {
          this.queryForm.starTime = this.PayTime[0]
          this.queryForm.endTime = this.PayTime[1]
          this.queryForm.pageNum = 1
          this.fetchData()
        }
      },
    },
  }
</script>
<style></style>
